home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: wkaufman@us.oracle.com (William Kaufman)
- Newsgroups: comp.lang.c,comp.lang.c.moderated
- Subject: Re: const pointer confusion...
- Date: 24 Mar 1996 11:48:14 -0600
- Organization: Oracle Corporation, Redwood Shores CA
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4j41su$nrj@solutions.solon.com>
- References: <4j06gm$7oa@solutions.solon.com>
- NNTP-Posting-Host: solutions.solon.com
-
- In article <4j06gm$7oa@solutions.solon.com> "Reed R. Mangino" <mangino@planet.net> writes:
- ] Could someone please straighten me out on this:
- ]
- ] 1) const int *p = 10;
- ] p is a constant pointer to an int, right?
-
- Eh, no, that'd be "int * const p". The definition above is a
- pointer to a constant int. (Slight difference, but an important one.)
-
- ] While p can be made to
- ] point to something else, *p can never be assigned to, right?
-
- Right.
-
- ] 2) int *const p;
- ] p is a pointer to an integer.
-
- "..._constant_ pointer to an integer".
-
- ] *p can be assigned to, but p can
- ] never be made to point to another address in memory, right?
-
- Right.
-
- ] 3) int const *p;
- ] What the heck is this? I can't find anything like this in my
- ] books, but my compiler thinks everything is hunky doory!???
-
- It's the same as "const int *p"--a pointer to a constant int. (This
- is one thing that bugs me about "const"--you can move it around. It's
- almost like it's both a storage class and a type specifier,...)
-
- -- Bill K.
-
- Bill Kaufman | "Made with the finest British attention
- wkaufman@us.oracle.com | to the wrong details."
- | -- Mark E. Smith
-